package com.example.demo.controller;

import com.example.demo.entity.Message;
import com.example.demo.mapper.MessageMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class MessageController {
    @Autowired(required = false)
    MessageMapper mapper;

    @RequestMapping("/add")
    public void add(@RequestBody Message message) {
        System.out.println("hahahahaha");
        System.out.println(message.getArticle());
        mapper.add(message);
    }
    @RequestMapping("/select")
    public List<Message> select(){
        return mapper.select();
    }
}
